package com.yunzhi.net.interceptor;

import androidx.annotation.NonNull;

import com.yunzhi.net.utils.AppConfig;
import com.yunzhi.net.utils.Utils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Author by Mr.Meng
 * created 2019/5/15
 *
 * @desc
 */
public class HttpHeaderInterceptor implements Interceptor {

    @NonNull
    @Override
    public Response intercept(@NonNull Chain chain) throws IOException {
        Request originalRequest = chain.request();


        Request authorised = originalRequest.newBuilder()
                .header("Content-type", "application/json")
                .header("Content-type", "application/x-www-form-urlencoded; charset=utf-8")
                .header("access_token", AppConfig.getAppConfig().getToken(Utils.getApp()))
                .removeHeader("Pragma").build();

        return chain.proceed(authorised);
    }
}